//
//  MusicTableViewCell.m
//  On The Load
//
//  Created by 许嘉成 on 15/11/14.
//  Copyright © 2015年 @@叶一闽. All rights reserved.
//

#import "MusicTableViewCell.h"
#import "UIImageView+WebCache.h"
#import "XJCMusciModel.h"

@interface MusicTableViewCell()

@property(nonatomic,retain)UIImageView *backImgView;//背景图
@property(nonatomic,retain)UILabel *titleLabel;//标题
@property(nonatomic,retain)UILabel *channelLabel;//频道
@property(nonatomic,retain)UIView *specialV;//3D图标

@end

@implementation MusicTableViewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createCell];
    }
    return self;
}
-(void)createCell
{
    self.backImgView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, WIDTH, 170*SCALEH)];
    [self.contentView addSubview:self.backImgView];
    
    UIImageView *shadowImg = [[UIImageView alloc]initWithFrame:self.backImgView.frame];
    shadowImg.image = [UIImage imageNamed:@"shadow.png"];
    [self.backImgView addSubview:shadowImg];
    shadowImg.alpha = 0.3;
    
    self.titleLabel = [[UILabel   alloc]initWithFrame:CGRectMake(WIDTH/6, 170/5*SCALEW, WIDTH/6*4, 170/3*SCALEH)];
    self.titleLabel.textAlignment = NSTextAlignmentCenter;
    self.titleLabel.numberOfLines = 0;
    self.titleLabel.textColor = [UIColor whiteColor];
    self.titleLabel.font =  [UIFont systemFontOfSize:19*SCALEW];
    [self.contentView addSubview:self.titleLabel];
    
    self.channelLabel = [[UILabel alloc]initWithFrame:CGRectMake(WIDTH/5,self.titleLabel.frame.origin.y + self.titleLabel.frame.size.height+10*SCALEH, WIDTH/5*2, 170/8*SCALEH)];
    self.channelLabel.textColor = [UIColor colorWithRed:0.545 green:0.902 blue:0.779 alpha:1.000];
    self.channelLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:15];
    //    self.channelLabel.backgroundColor = [UIColor colorWithRed:0.884 green:0.916 blue:0.630 alpha:1.000];
    self.channelLabel.textAlignment = NSTextAlignmentCenter;
    [self.contentView addSubview:self.channelLabel];
    
    
    UILabel *textLabel = [[UILabel alloc]initWithFrame:CGRectMake(self.channelLabel.frame.origin.x+self.channelLabel.frame.size.width+5, self.channelLabel.frame.origin.y, 50*SCALEW, self.channelLabel.frame.size.height)];
    //    textLabel.backgroundColor = [UIColor colorWithRed:0.198 green:0.787 blue:0.906 alpha:1.000];
    textLabel.textColor = [UIColor whiteColor];
    textLabel.text = @"频道";
    textLabel.textAlignment = NSTextAlignmentCenter;
    textLabel.font = [UIFont systemFontOfSize:15*SCALEW];
    [self.contentView addSubview:textLabel];
    //3D图标
    self.specialV = [[UIView alloc]initWithFrame:CGRectMake(10*SCALEW, 10*SCALEW, 30*SCALEW, 30*SCALEW)];
    self.specialV.backgroundColor = [UIColor colorWithRed:0.545 green:0.902 blue:0.779 alpha:1.000];
    self.specialV.layer.masksToBounds = YES;
    self.specialV.layer.cornerRadius = self.specialV.frame.size.width/2;
    self.specialV.hidden = YES;
    [self.contentView addSubview:self.specialV];
    
    UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, self.specialV.frame.size.width, self.specialV.frame.size.height)];
    label.font = [UIFont fontWithName:@"Helvetica-Bold" size:15*SCALEW];
    label.backgroundColor = [UIColor clearColor];
    label.text = @"3D";
    label.textColor = [UIColor whiteColor];
    label.textAlignment = NSTextAlignmentCenter;
    [self.specialV addSubview:label];
    
}
-(void)setMusicM:(XJCMusciModel *)musicM
{
    _musicM = musicM;
    
    [self.backImgView sd_setImageWithURL:[NSURL URLWithString:_musicM.pic_640] placeholderImage:nil];
    self.titleLabel.text = _musicM.name;
    self.channelLabel.text  = [_musicM.channel objectForKey:@"name"];
    if ([_musicM.status_mask isEqualToString:@"1"]) {
        self.specialV.hidden = NO;
    }
}




@end
